/*
 * Copyright (c) 2011 by Konstantin Pavlov.
 */

package gwtlx.html5.client.forms;

import com.google.gwt.dom.client.Element;

/**
 * NumberBox is a {@link TextBox} extension which supports valid number values.
 * Adds support for <code>min, max</code> and <code>step</code> attributes.
 * <p/>
 * Rendered like this: <code>&lt;input type="number" min="5" max="10" step="1" value="7"/&gt;</code>.
 *
 * @author Konstantin Pavlov
 * @version $LastChangedRevision: 15 $
 * @since 09.01.11
 */
public class NumberBox extends TextBox {

    public NumberBox() {
        super();
        getElement().setAttribute("type", "number");
    }

    protected NumberBox(Element element) {
        super(element);
        getElement().setAttribute("type", "number");
    }

    public void setMin(Number min) {
        Html5Helper.setNumericAttribute(this, "min", min);
    }

    public Double getMin() {
        return Html5Helper.getNumericAttribute(this, "min");
    }

    public void setMax(Number min) {
        Html5Helper.setNumericAttribute(this, "max", min);
    }

    public Double getMax() {
        return Html5Helper.getNumericAttribute(this, "max");
    }

    public void setStep(Number min) {
        Html5Helper.setNumericAttribute(this, "step", min);
    }

    public Double getStep() {
        return Html5Helper.getNumericAttribute(this, "step");
    }

    public void setDoubleValue(Number min) {
        Html5Helper.setNumericAttribute(this, "value", min);
    }

    public Double getDoubleValue() {
        return Html5Helper.getNumericAttribute(this, "value");
    }

}
